﻿using D3StatsClient.Model;
using D3StatsClient.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace D3StatsClient.Commands
{
    class ResumeSession : CommandBase
    {
        public override bool CanExecute(object parameter)
        {
            MainWindowViewModel mwvm = ViewModelManager<MainWindowViewModel>.ViewModel;

            if ((Properties.Settings.Default.EnableMultiProcessSupport
                && mwvm.IsSessionLoaded)
                && !mwvm.IsRecording
                && mwvm.IsContinuedSession)
            {
                return true;
            }

            if ((mwvm.IsSessionLoaded && mwvm.IsContinuedSession == true) && mwvm.IsRecording == false)
            {
                return true;
            }

            return false;
        }

        public override void Execute(object parameter)
        {
            MainWindowViewModel mwvm = ViewModelManager<MainWindowViewModel>.ViewModel;

            mwvm.provider.ResumeSession();

            mwvm.StartRecordingSessionCommand.Execute(null);
        }
    }
}
